#include "transmit.h"

extern UART_HandleTypeDef huart3;

__STATIC_INLINE void _tst_data_pack(TST_Data *src) {
	src->Fmt[0] = 0xEDU;
	src->Fmt[1] = 0xFCU;
	src->Fmt[2] = src->Heart;
	src->Fmt[3] = src->Breathe;
	src->Fmt[4] = src->Flag;
	src->Fmt[5] = src->Heart + src->Breathe + src->Flag;
	sprintf((char *)(&src->Fmt[6]), "%f", src->Std);
	src->Fmt[14] = 0xECU;
	src->Fmt[15] = 0xEFU;
}

void TST_send_to_net(TST_Data *src) {
	
	assert_param(src != NULL);
	_tst_data_pack(src);
	assert_param(huart3.gState == HAL_UART_STATE_READY);
	HAL_UART_Transmit(&huart3, src->Fmt, 16U, 10U);
}
